package data;
import java.util.Vector;

/**
 * 坦克数据类 - 纯数据结构
 */
public class TankData {
    // -------------------- 数据设计 --------------------
    private int x, y;                       // 坐标
    private int speed = 5;                  // 速度
    private int hp = 100;                   // 血量
    private int direction = 0;              // 方向 0上1右2下3左
    private int tankKind = 0;               // 类型 0我方1敌方
    private int state = 0;                  // 状态 0空闲1运行
    private Vector<BulletData> bulletPool;  // 子弹池
    private long lastShootTime;             // 上次射击时间
    // -------------------- 数据设计 --------------------

    public TankData(int tankKind, int x, int y, int direction) {
        this.tankKind = tankKind;
        this.x = x;
        this.y = y;
        this.direction = direction;
        this.bulletPool = new Vector<>();
        this.lastShootTime = 0;

        // 初始化子弹池
        int bulletCount = (tankKind == 0) ? 3 : 2; // 我方3发，敌方2发
        for (int i = 0; i < bulletCount; i++) {
            bulletPool.add(new BulletData(this));
        }
    }

    // getter和setter方法
    public int getX() { return x; }
    public void setX(int x) { this.x = x; }
    public int getY() { return y; }
    public void setY(int y) { this.y = y; }
    public int getSpeed() { return speed; }
    public void setSpeed(int speed) { this.speed = speed; }
    public int getHp() { return hp; }
    public void setHp(int hp) { this.hp = hp; }
    public int getDirection() { return direction; }
    public void setDirection(int direction) { this.direction = direction; }
    public int getState() { return state; }
    public void setState(int state) { this.state = state; }
    public int getTankKind() { return tankKind; }
    public Vector<BulletData> getBulletPool() { return bulletPool; }
    public long getLastShootTime() { return lastShootTime; }
    public void setLastShootTime(long lastShootTime) { this.lastShootTime = lastShootTime; }
}